import { create } from '../asyncActionCreator';

/**
 * 获取数据
 * @type {String}
 */
export const GET_DATA_REQUEST = 'request recommendation chart data';
export const GET_DATA_SUCCESS = 'request recommendation chart data success';
export const GET_DATA_FAILURE = 'request recommendation chart data failure';

export const getDataRequest = (key) => ({
	type: GET_DATA_REQUEST,
	payload: {
		key
	}
});

export const getDataSuccess = (key, data) => ({
	type: GET_DATA_SUCCESS,
	payload: {
		key,
		data
	}
});

export const getDataFailure = (key, message) => ({
	type: GET_DATA_FAILURE,
	payload: {
		key, 
		message
	}
});

export const RECOMMENDATION_FLOW_URL = '/api/data/ExaminationAnalysisRecommendation';
export const RECOMMENDATION_SOURCE_URL = '/api/data/ExaminationAnalysisRecommendationSource';

export const getRecommendationData = (url, key, params) => (
	create(url,
		getDataRequest.bind(null, key), 
		getDataSuccess.bind(null, key), 
		getDataFailure.bind(null, key), 
		params)
);
